home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-06-24 | 10.0 KB | 332 lines | [TEXT/MPS ] |
- // Copyright © 1994-95 by Apple Computer, Inc. All rights reserved.
- // ShapeCommands.h
-
- #ifndef __SHAPECOMMANDS__
- #define __SHAPECOMMANDS__
-
- // MacApp
-
- #ifndef __UCOMMAND__
- #include <UCommand.h>
- #endif
-
- #ifndef __UTEAROFFMENUVIEW__
- #include <UTearOffMenuView.h>
- #endif
-
- // DrawShapes
-
- #ifndef __BETTERFEEDBACK__
- #include "BetterFeedback.h"
- #endif
-
- #ifndef __USHAPELIST__
- #include "UShapeList.h"
- #endif
-
- //--------------------------------------------------------------------------------------------------
-
- class TPatternsPalette;
- class TShapeView;
- class TShapeDocument;
-
- //--------------------------------------------------------------------------------------------------
- // CLASS TShapeCommand - common ancestor for all commands operating on one or more shapes
- //--------------------------------------------------------------------------------------------------
- class TShapeCommand : public TBetterFeedbackCmd
- {
- MA_DECLARE_CLASS;
-
- public:
- TShapeCommand(); // Constructor
- void IShapeCommand(CommandNumber itsCommandNumber,
- TShapeView* itsShapeView,
- Boolean canUndo,
- Boolean causesChange,
- const VPoint& theMouse,
- Boolean betterFeedbackDesired);
-
- protected:
- TShapeView* fShapeView;
- TShapeDocument* fShapeDocument;
- };
-
- //--------------------------------------------------------------------------------------------------
- // CLASS TShapeSelector - this command demonstrates the use of a command object that is not saved
- // and that does not commit the last command. The same effect could have
- // been achieved by selecting the shapes in the TrackMouse method.
- //--------------------------------------------------------------------------------------------------
- class TShapeSelector : public TShapeCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- TShapeSelector(); // Constructor
- void IShapeSelector(CommandNumber itsCommandNumber,
- TShapeView* itsShapeView,
- const VPoint& theMouse);
-
- virtual void DoIt(); // Override
-
- virtual void TrackFeedback(TrackPhase aTrackPhase,
- const VPoint& anchorPoint,
- const VPoint& previousPoint,
- const VPoint& nextPoint,
- Boolean mouseDidMove,
- Boolean turnItOn); // Override
-
- virtual TTracker* TrackMouse(TrackPhase aTrackPhase,
- VPoint& anchorPoint,
- VPoint& previousPoint,
- VPoint& nextPoint,
- Boolean mouseDidMove); // Override
-
- private:
- long fLastMarch;
- Pattern fAnts;
- CRect fBounds;
- Boolean fShiftKey;
- };
-
- //--------------------------------------------------------------------------------------------------
- // CLASS TShapeDragger -
- //--------------------------------------------------------------------------------------------------
- class TShapeDragger : public TShapeCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- TShapeDragger(); // Constructor
- void IShapeDragger(TShapeView* itsShapeView,
- const VPoint& theMouse);
-
- virtual void DoIt(); // Override
- virtual void UndoIt(); // Override
- virtual void RedoIt(); // Override
-
- void MoveBy(long deltaH, long deltaV);
-
- virtual void TrackConstrain(TrackPhase aTrackPhase,
- const VPoint& anchorPoint,
- const VPoint& previousPoint,
- VPoint& nextPoint,
- Boolean mouseDidMove); // Override
- // Only if gConstrainDrags is true is a shapeDragger marked as constraining the mouse,
- // so be sure to make gConstrainDrags TRUE before mousing down on something you want to
- // drag under constraint.
- // You manipulate the gConstrainDrags flag through a toggle in the 'More Debug' menu,
- // which you get displayed by hitting Command-D.
-
- virtual void TrackFeedback(TrackPhase aTrackPhase,
- const VPoint& anchorPoint,
- const VPoint& previousPoint,
- const VPoint& nextPoint,
- Boolean mouseDidMove,
- Boolean turnItOn); // Override
-
- virtual TTracker* TrackMouse(TrackPhase aTrackPhase,
- VPoint& anchorPoint,
- VPoint& previousPoint,
- VPoint& nextPoint,
- Boolean mouseDidMove); // Override
-
- private:
- CRect fBounds; // Union of extents of all shapes being dragged, before the move
- long fDeltaH;
- long fDeltaV;
- };
-
- //--------------------------------------------------------------------------------------------------
- // CLASS TReshadeCmd -
- //--------------------------------------------------------------------------------------------------
- class TReshadeCmd : public TTearOffMenuViewTracker
- {
- MA_DECLARE_CLASS;
-
- public:
- TReshadeCmd(); // Constructor
- void IReshadeCmd(CommandNumber itsCommandNumber,
- TShapeView* itsShapeView,
- TPatternsPalette* thePatternsPalette,
- TPatternsPalette* menuPatternsPalette,
- TPatternsPalette* floatingPatternsPalette,
- const VPoint& theMouse);
-
- virtual TTracker* TrackMouse(TrackPhase aTrackPhase,
- VPoint& anchorPoint,
- VPoint& previousPoint,
- VPoint& nextPoint,
- Boolean mouseDidMove); // Override
-
- virtual void TrackFeedback(TrackPhase aTrackPhase,
- const VPoint& anchorPoint,
- const VPoint& previousPoint,
- const VPoint& nextPoint,
- Boolean mouseDidMove,
- Boolean turnItOn); // Override
-
- virtual Boolean IsDoneTracking(); // Override
-
- virtual void DoIt(); // Override
- virtual void UndoIt(); // Override
- virtual void RedoIt(); // Override
-
- private:
- TShapeView* fShapeView;
- TShapeDocument* fShapeDocument;
- short fPattern;
- Boolean fExitTracking;
- TPatternsPalette* fMenuPatternsPalette;
- TPatternsPalette* fFloatingPatternsPalette;
- };
-
- //--------------------------------------------------------------------------------------------------
- // CLASS TRecolorCmd - the set of shapes affected by the reshade request is defined by the
- // fWasSelected fields of the shapes themselves
- //--------------------------------------------------------------------------------------------------
- class TRecolorCmd : public TShapeCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- TRecolorCmd(); // Constructor
- void IRecolorCmd(CRGBColor itsColor, TShapeView* itsShapeView);
-
- virtual void DoIt(); // Override
- virtual void UndoIt(); // Override
- virtual void RedoIt(); // Override
-
- private:
- CRGBColor fColor;
- };
-
- //--------------------------------------------------------------------------------------------------
- // CLASS TShapeReplaceCommand -
- //--------------------------------------------------------------------------------------------------
- class TShapeReplaceCommand : public TShapeCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- TShapeReplaceCommand(); // Constructor
- void IShapeReplaceCommand(CommandNumber itsCommandNumber,
- TShapeView* itsShapeView,
- const VPoint& theMouse,
- Boolean betterFeedbackDesired);
-
- virtual void Commit(); // Override
- virtual void UndoIt(); // Override
- virtual void RedoIt(); // Override
-
- virtual void EachNewShapeDo(DoToShapeType DoToShape, void* staticLink);
- };
-
- //--------------------------------------------------------------------------------------------------
- // CLASS TShapeSketcher -
- //--------------------------------------------------------------------------------------------------
- class TShapeSketcher : public TShapeReplaceCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- TShapeSketcher(); // Constructor
- void IShapeSketcher(TShapeView* itsShapeView,
- TShape* protoShape,
- const VPoint& theMouse,
- Boolean constrain);
-
- virtual void Free(); // Override
-
- // • Command performing
- virtual void Commit(); // Override
- virtual void DoIt(); // Override
- virtual void UndoIt(); // Override
- virtual void RedoIt(); // Override
-
- virtual void EachNewShapeDo(DoToShapeType DoToShape, void* staticLink); // Override
-
- virtual void TrackConstrain(TrackPhase aTrackPhase,
- const VPoint& anchorPoint,
- const VPoint& previousPoint,
- VPoint& nextPoint,
- Boolean mouseDidMove); // Override
-
- virtual void TrackFeedback(TrackPhase aTrackPhase,
- const VPoint& anchorPoint,
- const VPoint& previousPoint,
- const VPoint& nextPoint,
- Boolean mouseDidMove,
- Boolean turnItOn); // Override
-
- virtual TTracker* TrackMouse(TrackPhase aTrackPhase,
- VPoint& anchorPoint,
- VPoint& previousPoint,
- VPoint& nextPoint,
- Boolean mouseDidMove); // Override
-
- private:
- TShape* fShape; // the shape sketched by the user
- };
-
- //--------------------------------------------------------------------------------------------------
- // CLASS TShapeCutCopyCommand -
- //--------------------------------------------------------------------------------------------------
- class TShapeCutCopyCommand : public TShapeReplaceCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- TShapeCutCopyCommand(); // Constructor
- void IShapeCutCopyCommand(CommandNumber itsCommandNumber,
- TShapeView* itsShapeView);
-
- virtual void DoIt(); // Override
- virtual void RedoIt(); // Override
- };
-
- //--------------------------------------------------------------------------------------------------
- // CLASS TShapeClearCommand -
- //--------------------------------------------------------------------------------------------------
- class TShapeClearCommand : public TShapeReplaceCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- TShapeClearCommand(); // Constructor
- void IShapeClearCommand(TShapeView* itsShapeView);
-
- virtual void DoIt(); // Override
- virtual void RedoIt(); // Override
- };
-
- //--------------------------------------------------------------------------------------------------
- // CLASS TShapePasteCommand -
- //--------------------------------------------------------------------------------------------------
- class TShapePasteCommand : public TShapeReplaceCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- TShapePasteCommand(); // Constructor
- void IShapePasteCommand(TShapeView* itsShapeView);
-
- virtual void Free(); // Override
-
- // • Command performing
- virtual void Commit(); // Override
- virtual void DoIt(); // Override
- virtual void UndoIt(); // Override
- virtual void RedoIt(); // Override
-
- virtual void EachNewShapeDo(DoToShapeType DoToShape, void* staticLink); // Override
-
- void PasteShapes(CPoint whereToPaste);
- void PastePict(CPoint whereToPaste);
- void PasteText(CPoint whereToPaste);
-
- private:
- TShapeList* fPasteList;
- };
-
- #endif
-